﻿@page "/gatewayruntime/realalarm"
@using System.Linq.Expressions;
@using BlazorComponent;
@using Masa.Blazor.Presets;
@using Microsoft.AspNetCore.Authorization;
@using Microsoft.Extensions.DependencyInjection
@using System.Collections.Concurrent
@using ThingsGateway.Admin.Application;
@using ThingsGateway.Admin.Blazor
@using ThingsGateway.Core.Extension
@using ThingsGateway.Foundation
@using ThingsGateway.Gateway.Application

@namespace ThingsGateway.Gateway.Blazor
@attribute [Authorize]
@inject UserResoures UserResoures
@attribute [RolePermission]
@inherits BaseComponentBase

@code {
    private List<Device> _queryDevices = new();
    private void DeviceQuerySelections(string v)
    {
        if (string.IsNullOrEmpty(v))
        {
            return;
        }
        _queryDevices = _devices.Where(e => e.Name.ToLowerInvariant().IndexOf(v.ToLowerInvariant()) > -1).OrderBy(a => a.Name.Length).Take(20).ToList();
    }


}
<AppDataTable @ref="_datatable" TItem="AlarmVariable" SearchItem="AlarmVariablePageInput"               
    AddItem="object" EditItem="object" IsShowSelect=false 
              SearchModel="@_search" IsShowSearchKey
               QueryCallAsync="QueryCallAsync" 
               IsMenuOperTemplate=false AddWidth="1600" EditWidth="1600"
                IsShowDetailButton
                IsShowQueryButton>

     <SearchTemplate>

         <MTextField Dense Style="max-width:200px;" HideDetails=@("auto") Class="my-1 mx-2 " Outlined Clearable
                     @bind-Value="context.Name" Label=@AppService.I18n.T(context.Description(x => x.Name)) />

         <MTextField Dense Style="max-width:200px;" HideDetails=@("auto") Class="my-1 mx-2 " Outlined Clearable
                     @bind-Value="context.RegisterAddress" Label=@AppService.I18n.T(context.Description(x => x.RegisterAddress)) />

         <MAutocomplete Dense Style="max-width:200px;" HideDetails=@("auto") Class="my-1 mx-2 " CacheItems HideNoData Outlined
                        ItemValue="r=>r.Name" ItemText="r=>r.Name" OnSearchInputUpdate="DeviceQuerySelections"
                        Items="_queryDevices" Flat Clearable
                        @bind-Value="context.DeviceName" Label=@AppService.I18n.T(context.Description(x => x.DeviceName)) />


     </SearchTemplate>



    
</AppDataTable>




